#pragma once
// MESSAGE KF_XK_P2 PACKING

#define MAVLINK_MSG_ID_KF_XK_P2 27

MAVPACKED(
typedef struct __mavlink_kf_xk_p2_t {
 float delta_xk[30]; /*<  delta_xk*/
 float xk_total[30]; /*<  xk_total*/
}) mavlink_kf_xk_p2_t;

#define MAVLINK_MSG_ID_KF_XK_P2_LEN 240
#define MAVLINK_MSG_ID_KF_XK_P2_MIN_LEN 240
#define MAVLINK_MSG_ID_27_LEN 240
#define MAVLINK_MSG_ID_27_MIN_LEN 240

#define MAVLINK_MSG_ID_KF_XK_P2_CRC 158
#define MAVLINK_MSG_ID_27_CRC 158

#define MAVLINK_MSG_KF_XK_P2_FIELD_DELTA_XK_LEN 30
#define MAVLINK_MSG_KF_XK_P2_FIELD_XK_TOTAL_LEN 30

#if MAVLINK_COMMAND_24BIT
#define MAVLINK_MESSAGE_INFO_KF_XK_P2 { \
    27, \
    "KF_XK_P2", \
    2, \
    {  { "delta_xk", NULL, MAVLINK_TYPE_FLOAT, 30, 0, offsetof(mavlink_kf_xk_p2_t, delta_xk) }, \
         { "xk_total", NULL, MAVLINK_TYPE_FLOAT, 30, 120, offsetof(mavlink_kf_xk_p2_t, xk_total) }, \
         } \
}
#else
#define MAVLINK_MESSAGE_INFO_KF_XK_P2 { \
    "KF_XK_P2", \
    2, \
    {  { "delta_xk", NULL, MAVLINK_TYPE_FLOAT, 30, 0, offsetof(mavlink_kf_xk_p2_t, delta_xk) }, \
         { "xk_total", NULL, MAVLINK_TYPE_FLOAT, 30, 120, offsetof(mavlink_kf_xk_p2_t, xk_total) }, \
         } \
}
#endif

/**
 * @brief Pack a kf_xk_p2 message
 * @param system_id ID of this system
 * @param component_id ID of this component (e.g. 200 for IMU)
 * @param msg The MAVLink message to compress the data into
 *
 * @param delta_xk  delta_xk
 * @param xk_total  xk_total
 * @return length of the message in bytes (excluding serial stream start sign)
 */
static inline uint16_t mavlink_msg_kf_xk_p2_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
                               const float *delta_xk, const float *xk_total)
{
#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
    char buf[MAVLINK_MSG_ID_KF_XK_P2_LEN];

    _mav_put_float_array(buf, 0, delta_xk, 30);
    _mav_put_float_array(buf, 120, xk_total, 30);
        memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_KF_XK_P2_LEN);
#else
    mavlink_kf_xk_p2_t packet;

    mav_array_memcpy(packet.delta_xk, delta_xk, sizeof(float)*30);
    mav_array_memcpy(packet.xk_total, xk_total, sizeof(float)*30);
        memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_KF_XK_P2_LEN);
#endif

    msg->msgid = MAVLINK_MSG_ID_KF_XK_P2;
    return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_KF_XK_P2_MIN_LEN, MAVLINK_MSG_ID_KF_XK_P2_LEN, MAVLINK_MSG_ID_KF_XK_P2_CRC);
}

/**
 * @brief Pack a kf_xk_p2 message on a channel
 * @param system_id ID of this system
 * @param component_id ID of this component (e.g. 200 for IMU)
 * @param chan The MAVLink channel this message will be sent over
 * @param msg The MAVLink message to compress the data into
 * @param delta_xk  delta_xk
 * @param xk_total  xk_total
 * @return length of the message in bytes (excluding serial stream start sign)
 */
static inline uint16_t mavlink_msg_kf_xk_p2_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
                               mavlink_message_t* msg,
                                   const float *delta_xk,const float *xk_total)
{
#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
    char buf[MAVLINK_MSG_ID_KF_XK_P2_LEN];

    _mav_put_float_array(buf, 0, delta_xk, 30);
    _mav_put_float_array(buf, 120, xk_total, 30);
        memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_KF_XK_P2_LEN);
#else
    mavlink_kf_xk_p2_t packet;

    mav_array_memcpy(packet.delta_xk, delta_xk, sizeof(float)*30);
    mav_array_memcpy(packet.xk_total, xk_total, sizeof(float)*30);
        memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_KF_XK_P2_LEN);
#endif

    msg->msgid = MAVLINK_MSG_ID_KF_XK_P2;
    return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_KF_XK_P2_MIN_LEN, MAVLINK_MSG_ID_KF_XK_P2_LEN, MAVLINK_MSG_ID_KF_XK_P2_CRC);
}

/**
 * @brief Encode a kf_xk_p2 struct
 *
 * @param system_id ID of this system
 * @param component_id ID of this component (e.g. 200 for IMU)
 * @param msg The MAVLink message to compress the data into
 * @param kf_xk_p2 C-struct to read the message contents from
 */
static inline uint16_t mavlink_msg_kf_xk_p2_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_kf_xk_p2_t* kf_xk_p2)
{
    return mavlink_msg_kf_xk_p2_pack(system_id, component_id, msg, kf_xk_p2->delta_xk, kf_xk_p2->xk_total);
}

/**
 * @brief Encode a kf_xk_p2 struct on a channel
 *
 * @param system_id ID of this system
 * @param component_id ID of this component (e.g. 200 for IMU)
 * @param chan The MAVLink channel this message will be sent over
 * @param msg The MAVLink message to compress the data into
 * @param kf_xk_p2 C-struct to read the message contents from
 */
static inline uint16_t mavlink_msg_kf_xk_p2_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_kf_xk_p2_t* kf_xk_p2)
{
    return mavlink_msg_kf_xk_p2_pack_chan(system_id, component_id, chan, msg, kf_xk_p2->delta_xk, kf_xk_p2->xk_total);
}

/**
 * @brief Send a kf_xk_p2 message
 * @param chan MAVLink channel to send the message
 *
 * @param delta_xk  delta_xk
 * @param xk_total  xk_total
 */
#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS

static inline void mavlink_msg_kf_xk_p2_send(mavlink_channel_t chan, const float *delta_xk, const float *xk_total)
{
#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
    char buf[MAVLINK_MSG_ID_KF_XK_P2_LEN];

    _mav_put_float_array(buf, 0, delta_xk, 30);
    _mav_put_float_array(buf, 120, xk_total, 30);
    _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_KF_XK_P2, buf, MAVLINK_MSG_ID_KF_XK_P2_MIN_LEN, MAVLINK_MSG_ID_KF_XK_P2_LEN, MAVLINK_MSG_ID_KF_XK_P2_CRC);
#else
    mavlink_kf_xk_p2_t packet;

    mav_array_memcpy(packet.delta_xk, delta_xk, sizeof(float)*30);
    mav_array_memcpy(packet.xk_total, xk_total, sizeof(float)*30);
    _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_KF_XK_P2, (const char *)&packet, MAVLINK_MSG_ID_KF_XK_P2_MIN_LEN, MAVLINK_MSG_ID_KF_XK_P2_LEN, MAVLINK_MSG_ID_KF_XK_P2_CRC);
#endif
}

/**
 * @brief Send a kf_xk_p2 message
 * @param chan MAVLink channel to send the message
 * @param struct The MAVLink struct to serialize
 */
static inline void mavlink_msg_kf_xk_p2_send_struct(mavlink_channel_t chan, const mavlink_kf_xk_p2_t* kf_xk_p2)
{
#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
    mavlink_msg_kf_xk_p2_send(chan, kf_xk_p2->delta_xk, kf_xk_p2->xk_total);
#else
    _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_KF_XK_P2, (const char *)kf_xk_p2, MAVLINK_MSG_ID_KF_XK_P2_MIN_LEN, MAVLINK_MSG_ID_KF_XK_P2_LEN, MAVLINK_MSG_ID_KF_XK_P2_CRC);
#endif
}

#if MAVLINK_MSG_ID_KF_XK_P2_LEN <= MAVLINK_MAX_PAYLOAD_LEN
/*
  This varient of _send() can be used to save stack space by re-using
  memory from the receive buffer.  The caller provides a
  mavlink_message_t which is the size of a full mavlink message. This
  is usually the receive buffer for the channel, and allows a reply to an
  incoming message with minimum stack space usage.
 */
static inline void mavlink_msg_kf_xk_p2_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan,  const float *delta_xk, const float *xk_total)
{
#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
    char *buf = (char *)msgbuf;

    _mav_put_float_array(buf, 0, delta_xk, 30);
    _mav_put_float_array(buf, 120, xk_total, 30);
    _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_KF_XK_P2, buf, MAVLINK_MSG_ID_KF_XK_P2_MIN_LEN, MAVLINK_MSG_ID_KF_XK_P2_LEN, MAVLINK_MSG_ID_KF_XK_P2_CRC);
#else
    mavlink_kf_xk_p2_t *packet = (mavlink_kf_xk_p2_t *)msgbuf;

    mav_array_memcpy(packet->delta_xk, delta_xk, sizeof(float)*30);
    mav_array_memcpy(packet->xk_total, xk_total, sizeof(float)*30);
    _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_KF_XK_P2, (const char *)packet, MAVLINK_MSG_ID_KF_XK_P2_MIN_LEN, MAVLINK_MSG_ID_KF_XK_P2_LEN, MAVLINK_MSG_ID_KF_XK_P2_CRC);
#endif
}
#endif

#endif

// MESSAGE KF_XK_P2 UNPACKING


/**
 * @brief Get field delta_xk from kf_xk_p2 message
 *
 * @return  delta_xk
 */
static inline uint16_t mavlink_msg_kf_xk_p2_get_delta_xk(const mavlink_message_t* msg, float *delta_xk)
{
    return _MAV_RETURN_float_array(msg, delta_xk, 30,  0);
}

/**
 * @brief Get field xk_total from kf_xk_p2 message
 *
 * @return  xk_total
 */
static inline uint16_t mavlink_msg_kf_xk_p2_get_xk_total(const mavlink_message_t* msg, float *xk_total)
{
    return _MAV_RETURN_float_array(msg, xk_total, 30,  120);
}

/**
 * @brief Decode a kf_xk_p2 message into a struct
 *
 * @param msg The message to decode
 * @param kf_xk_p2 C-struct to decode the message contents into
 */
static inline void mavlink_msg_kf_xk_p2_decode(const mavlink_message_t* msg, mavlink_kf_xk_p2_t* kf_xk_p2)
{
#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
    mavlink_msg_kf_xk_p2_get_delta_xk(msg, kf_xk_p2->delta_xk);
    mavlink_msg_kf_xk_p2_get_xk_total(msg, kf_xk_p2->xk_total);
#else
        uint8_t len = msg->len < MAVLINK_MSG_ID_KF_XK_P2_LEN? msg->len : MAVLINK_MSG_ID_KF_XK_P2_LEN;
        memset(kf_xk_p2, 0, MAVLINK_MSG_ID_KF_XK_P2_LEN);
    memcpy(kf_xk_p2, _MAV_PAYLOAD(msg), len);
#endif
}
